/*******************************************************************************
 * Copyright 2011 See AUTHORS file.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

package com.asg.guesswhat;

import com.asg.guesswhat.errors.RowColMaxExceedException;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

public class Assets {
	final private static int STANDARD_WIDTH = 6;
	final private static int STANDARD_HEIGHT = 4;
	
	public static Texture background;
	public static TextureRegion backgroundRegion;
	
	public static Texture splashScreen;
	public static TextureRegion splashScreenRegion;

	public static Texture assets;
	public static TextureRegion yourMove;
	public static TextureRegion newGame;
	public static TextureRegion boxMiddle;
	
	public static Sound clickSound;
	
	//public static GWSQLHandler sqlHandler;
	public static CardSet cardSet;
	public static GameBoard gameBoard;
	
	public static int hostID;

	public static Texture loadTexture (String file) {
		return new Texture(Gdx.files.internal(file));
	}

	public static void load() {
		cardSet = new CardSet();
		//sqlHandler = new GWSQLHandler();
		//splashScreen = loadTexture("data/splashScreen.png");
		//splashScreenRegion = new TextureRegion(splashScreen, 0, 0, 320, 480);
		
		background = loadTexture("data/menubackground.png");
		backgroundRegion = new TextureRegion(background, 0, 0, 320, 480);

		assets = loadTexture("data/gwassets.png");
		yourMove = new TextureRegion(assets, 0, 0, 255, 52);
		newGame = new TextureRegion(assets, 0, 117, 255, 50);
		boxMiddle = new TextureRegion(assets, 0, 52, 255, 65);
		
		clickSound = Gdx.audio.newSound(Gdx.files.internal("data/click.wav"));
		cardSet = new CardSet(Settings.cardSetObj);
	}

	public static void playSound (Sound sound) {
		if (Settings.soundEnabled) sound.play(1);
	}
	
	public static void loadGameBoard(){
		try {
		gameBoard = new GameBoard(STANDARD_HEIGHT, STANDARD_WIDTH, cardSet);
		} catch (RowColMaxExceedException e) {
		// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static String buildGameState(int hostID,int oppID,String command){
		return "";
	}
}
